Skip to content

fix: 启动任务失败时更详细的日志 - #340

Merged
MistEO merged 5 commits into
MistEO:mainfrom
HarcoChen:fix/errormessage
Sep 8, 2026
Merged

fix: 启动任务失败时更详细的日志#340
MistEO merged 5 commits into
MistEO:mainfrom
HarcoChen:fix/errormessage

Conversation

@HarcoChen

@HarcoChen HarcoChen commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

WebUI在启动任务失败时仅会报“未能通过快捷键开始任务”,即使对于开机自启动或是参数启动也是如此,容易引起疑惑。
细化了WebUI的启动失败报错,以形如“任务启动失败:具体原因”的形式打印

Sourcery 总结

通过在所有启动方式中显示具体失败原因,改进任务启动失败报告。

错误修复:

  • 任务启动失败时提供具体的本地化原因,而不是使用通用的热键专用错误信息。

增强功能:

  • 统一任务验证、设备发现、控制器设置、连接、资源加载和任务执行过程中的启动失败处理。
  • 将热键专用的成功和检测日志限制为实际由热键触发的启动,同时保留所有启动路径的详细失败日志。

杂项:

  • 为新显示的启动失败原因添加本地化消息,并移除已废弃的通用热键失败消息。
Original summary in English

Sourcery 摘要

为任务启动失败提供跨启动方式一致且具体的本地化错误信息。

错误修复:

  • 为所有任务启动路径显示带有具体本地化原因的失败信息,替代通用的快捷键启动失败提示。

改进:

  • 统一任务校验、设备或窗口发现、控制器配置、连接、资源加载及任务执行阶段的启动失败处理,并确保失败后恢复空闲状态。
  • 仅在任务确实由快捷键触发时记录快捷键检测和成功日志,同时保留其他启动方式的详细失败日志。

维护:

  • 补充多语言启动失败原因文案,并移除已废弃的快捷键专用失败文案。
Original summary in English

Sourcery 总结

在所有启动方式中,当任务无法启动时,显示本地化且具体的原因。

Bug 修复:

  • 当任务启动失败时,提供本地化且具体的原因,而不是通用的热键专用错误。

增强功能:

  • 统一任务验证、设备和窗口发现、控制器配置、连接、资源加载及任务执行过程中的启动失败报告,并在失败后将实例恢复为空闲状态。
  • 将热键检测和成功日志限制为实际由热键启动的任务,同时保留所有启动路径的详细失败日志。
  • 将未完成的主要任务报告为警告,并跳过后续任务,而不将整个启动流程视为通用失败。

维护工作:

  • 为新的启动失败原因添加本地化消息,并移除已废弃的通用热键启动失败消息。
Original summary in English

Summary by Sourcery

Show a localized, specific reason whenever task startup cannot proceed across all launch methods.

Bug Fixes:

  • Provide localized, specific reasons when task startup fails instead of the generic hotkey-specific error.

Enhancements:

  • Standardize startup failure reporting across task validation, device and window discovery, controller configuration, connection, resource loading, and task execution, while restoring the instance to an idle state after failures.
  • Limit hotkey detection and success logs to tasks actually started by a hotkey, while retaining detailed failure logs for every startup path.
  • Report incomplete primary tasks as a warning and skip trailing tasks without treating the overall startup flow as a generic failure.

Chores:

  • Add localized messages for new startup failure reasons and remove the obsolete generic hotkey startup failure message.
Original summary in English
Original summary in English

先前部分分支直接return false导致快捷键处理兜底,web区只打印快捷键启动任务失败,造成误解

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好——我已经审阅了你的更改,看起来很棒!


Sourcery 对开源项目免费——如果你喜欢我们的评审,请考虑分享它们 ✨
Original comment in English

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

# Conflicts:
#	src/components/Toolbar.tsx
@MistEO

MistEO commented Sep 7, 2026

Copy link
Copy Markdown
Owner

冲突了,康康

@HarcoChen

Copy link
Copy Markdown
Contributor Author

@sourcery-ai reivew

@sourcery-ai

sourcery-ai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Sure! I'm generating a new review now.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嘿——我发现了 1 个问题

给 AI Agent 的提示
请处理这次代码审查中的评论:

## 个别评论

### 评论 1
<location path="src/components/Toolbar.tsx" line_range="1312" />
<code_context>
           if (!primaryResult.allDone || primaryResult.stopped) {
-            log.warn(`实例 ${targetInstance.name}: 前段任务未正常结束,跳过收尾特殊任务`);
-            return false;
+            const message = t('taskList.autoConnect.primaryTasksIncomplete');
+            log.warn(`实例 ${targetInstance.name}: ${message}`);
+            addLog(targetId, { type: 'warning', message });
+            onPhaseChange?.('idle');
+            return true;
           }
           const trailingTaskIds = await runTaskBatch(trailing, false, '收尾', true);
</code_context>
<issue_to_address>
**问题 (bug_risk):** 当主要批次停止或失败时,该函数会记录警告,但返回 `true`,因此快捷键调用方会记录 `hotkeyStartSuccess`,而计划任务调用方会将此次运行视为已成功启动,尽管主要任务并未正常完成,且收尾任务也被跳过。

**触发条件:** 任务列表包含收尾任务,并且 `waitForTasks` 报告 `allDone === false``stopped === true` 时。

**建议修复:** 对于未成功完成的主要批次返回 `false`,同时保留特定的 `primaryTasksIncomplete` 日志,以便调用方不会发出成功结果。

```suggestion
            return false;
```
</issue_to_address>

Sourcery 对开源项目免费——如果您喜欢我们的审查,请考虑分享 ✨
Original comment in English

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/components/Toolbar.tsx" line_range="1312" />
<code_context>
           if (!primaryResult.allDone || primaryResult.stopped) {
-            log.warn(`实例 ${targetInstance.name}: 前段任务未正常结束,跳过收尾特殊任务`);
-            return false;
+            const message = t('taskList.autoConnect.primaryTasksIncomplete');
+            log.warn(`实例 ${targetInstance.name}: ${message}`);
+            addLog(targetId, { type: 'warning', message });
+            onPhaseChange?.('idle');
+            return true;
           }
           const trailingTaskIds = await runTaskBatch(trailing, false, '收尾', true);
</code_context>
<issue_to_address>
**issue (bug_risk):** When the primary batch stops or fails, the function logs a warning but returns `true`, so hotkey callers record `hotkeyStartSuccess` and scheduled callers treat the run as successfully started even though the primary tasks did not finish normally and the trailing tasks were skipped.

**Triggers:** When a task list has trailing tasks and `waitForTasks` reports `allDone === false` or `stopped === true`.

**Suggested fix:** Return `false` for an unsuccessful primary batch, while preserving the specific `primaryTasksIncomplete` log so callers do not emit a success result.

```suggestion
            return false;
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

log.warn(`实例 ${targetInstance.name}: ${message}`);
addLog(targetId, { type: 'warning', message });
onPhaseChange?.('idle');
return true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问题 (bug_risk): 当主要批次停止或失败时,该函数会记录警告,但返回 true,因此快捷键调用方会记录 hotkeyStartSuccess,而计划任务调用方会将此次运行视为已成功启动,尽管主要任务并未正常完成,且收尾任务也被跳过。

触发条件: 任务列表包含收尾任务,并且 waitForTasks 报告 allDone === falsestopped === true 时。

建议修复: 对于未成功完成的主要批次返回 false,同时保留特定的 primaryTasksIncomplete 日志,以便调用方不会发出成功结果。

Suggested change
return true;
return false;
Original comment in English

issue (bug_risk): When the primary batch stops or fails, the function logs a warning but returns true, so hotkey callers record hotkeyStartSuccess and scheduled callers treat the run as successfully started even though the primary tasks did not finish normally and the trailing tasks were skipped.

Triggers: When a task list has trailing tasks and waitForTasks reports allDone === false or stopped === true.

Suggested fix: Return false for an unsuccessful primary batch, while preserving the specific primaryTasksIncomplete log so callers do not emit a success result.

Suggested change
return true;
return false;

@sourcery-ai

sourcery-ai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Hey @HarcoChen, I've posted a new review for you!

@MistEO
MistEO merged commit 5aa82bf into MistEO:main Sep 8, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants